package com.wrl.mmall.controller.backend;

import com.wrl.mmall.common.ServerResponse;
import com.wrl.mmall.service.IOrderService;
import com.wrl.mmall.vo.OrderVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 后端 订单管理
 * Created by Wang Renlei on 2018/9/20.
 */
@Controller
@RequestMapping("manage/order")
public class OrderManageController {

    @Autowired
    private IOrderService iOrderService;

    /**
     * 管理员查询订单list
     */
    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse<PageInfo> orderList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                              @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        return iOrderService.getManageList(pageNum, pageSize);
    }

    /**
     * 管理员获取订单详情
     */
    @RequestMapping("order_detail.do")
    @ResponseBody
    public ServerResponse<OrderVo> orderDetail(Long orderNo) {
        return iOrderService.getManageDetail(orderNo);
    }

    /**
     * 后台查询订单（目前只有订单id，后期扩展为模糊查询）
     */
    @RequestMapping("search.do")
    @ResponseBody
    public ServerResponse<PageInfo> search(Long orderNo,
                                           @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                           @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        return iOrderService.getOrderSearch(orderNo, pageNum, pageSize);
    }

    /**
     * 后台发货
     */
    @RequestMapping("send_goods.do")
    @ResponseBody
    public ServerResponse<String> orderSendGoods(Long orderNo) {
        return iOrderService.orderSendGoods(orderNo);
    }

}
